<?php

namespace App\Jobs\RemoveDelCatalogData;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;


class UpdatePdfTable implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $list2;
    protected $pdfTable;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($list2, $pdfTable)
    {
        $this->list2    = $list2;
        $this->pdfTable = $pdfTable;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $list2    = $this->list2;
        $pdfTable = $this->pdfTable;
        foreach ($list2 as $val2) {
            info($val2->pre_id);
            $updatePdfRes = DB::table($pdfTable)->where('book_catalog_id', $val2->pre_id)->update(['book_catalog_id' => $val2->id]);
            info('$updatePdfRes:'.$updatePdfRes);
        }
    }

}
